/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ViewXML.java
 *
 * Created on 23.09.2010, 20:32:34
 */
package org.simplexquery;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import jsyntaxpane.DefaultSyntaxKit;

/**
 *
 * @author klaus
 */
public class ViewXML extends javax.swing.JFrame {

    /** Creates new form ViewXML */
    public ViewXML() {
        initComponents();
        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
        this.setLocation((d.width - this.getSize().width) / 2, (d.height - this.getSize().height) / 2);

        DefaultSyntaxKit.initKit();
//
//        final JEditorPane codeEditor = new JEditorPane();
//        jScrollPane1.add(codeEditor);
//
//        codeEditor.setContentType("text/xml");
//        this.setSize(800, 600);
//        //this.setVisible(true);
//        codeEditor.setText("<hallo/>");
//        System.out.println("test");

        final Container c = this.getContentPane();
        c.setLayout(new BorderLayout());

        DefaultSyntaxKit.initKit();

        //final JEditorPane
        codeEditor = new JEditorPane();
        JScrollPane scrPane = new JScrollPane(codeEditor);
        c.add(scrPane, BorderLayout.CENTER);
        c.doLayout();
        codeEditor.setContentType("text/xml");
        //codeEditor.setText("<hallo>test</hallo>");

        codeEditor.setEditable(false);
        this.setSize(800, 600);
        
    }

    public void setParent(Object o) {
        parent = o;
    }

    public void setXML(String xml) {
        codeEditor.setText(xml);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.simplexquery.App.class).getContext().getResourceMap(ViewXML.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setName("Form"); // NOI18N
        getContentPane().setLayout(new java.awt.GridLayout());

        jScrollPane1.setMinimumSize(new java.awt.Dimension(240, 240));
        jScrollPane1.setName("jScrollPane1"); // NOI18N
        getContentPane().add(jScrollPane1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ViewXML().setVisible(true);

            }
        });
    }
    private Object parent = null;
    JEditorPane codeEditor = null;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
